<%@page import="com.shsh.safemanage.dao.PostCheckDao"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.Role"%>
<%@page import="com.shsh.safemanage.model.Department3"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.Set"%>
<%@page import="com.shsh.safemanage.dao.TitlePostManageGroupDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<%
{
User registerUser = (User) session.getAttribute(Constants.SESSION_USER);
String next = (String) session.getAttribute(Constants.SESSION_REGISTER_NEXT);
DepartmentDao theDepartmentDao = DaoCreator.createDepartmentDao();
TitlePostManageGroupDao tpmDao = DaoCreator.createTitlePostManageGroupDao();
EquipmentDao theEquipmentDao = DaoCreator.createEquipmentDao();
PostCheckDao thePostCheckDao = DaoCreator.createPostCheckDao();

Department3 theDepartment3 = theDepartmentDao.getDepartment3ByID(registerUser.getDepartment3ID());
Role theRole = tpmDao.getRoleByID(theDepartment3.getRoleID());

Set<Equipment> equipmentSet = theEquipmentDao.getUserMappingEquipmentList(registerUser.getId(), false);
Set<ManageGroup> managegroupSet = tpmDao.getUserMappingManageGroup(registerUser.getId());
Set<PostCheck> postcheckSet = thePostCheckDao.getUserMappingPostcheck(registerUser.getId());
Set<Department1> mappingDepart1Set = theDepartmentDao.getUserMappingDepartment1Set(registerUser.getId());

session.setAttribute(Constants.SESSION_MAPPING_EQUIPMENT, equipmentSet);
session.setAttribute(Constants.SESSION_MANAGE_GROUP_SET, managegroupSet);
session.setAttribute(Constants.SESSION_MAPPING_POSTCHECK_SET, postcheckSet);
session.setAttribute(Constants.SESSION_MAPPING_SHIYEBU, mappingDepart1Set);
%>
<table align="center" border="1" width="700" cellpadding="0"
	cellspacing="0">
	<%
	if ((theRole.getRoleType() & (Constants.ROLE_TYPE_ZUYUAN | Constants.ROLE_TYPE_ZUZHANG | Constants.ROLE_TYPE_ZHUANGZHIZHANG
			| Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
			| Constants.ROLE_TYPE_KEYUAN | Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
	%>
	<%
	Department1 theDepart1 = theDepartmentDao.getDepartment1ByID(registerUser.getDepartment1ID());
	if (theDepart1.getDepartmentType() == Constants.DEPARTMENT_TYPE_JIGUAN) {
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">对口作业部：</span>
			<%@include file="depart_select/depart1_shiyebu_select_section.jsp" %>
			<input type="button" value="添加" onclick="chooseMappingShiyebu()" />
			<span id="depart1ListSpan">
			<%@include file="depart1_list_section.jsp" %>
			</span>
		</td>
	</tr>
	<%
	}
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">对口装置：</span>
			<%@include file="depart_select/equip_select_section.jsp" %>
			<input type="button" value="添加" onclick="chooseMappingEquip()" />
			<span id="equipListSpan">
			<%@include file="equip_list_section.jsp" %>
			</span>
<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp由于检查问题均交由装置长分配，故作业部（业务中心）选择对口装置时要注意如下事项：
<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp1、组员千万不要选择！！！！<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp2、组长（不兼任装置长）千万不要选择！！！！兼任装置长的组长请选择对口装置。<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp3、安全总监（不兼任装置长）千万不要选择！！！！兼任装置长的安全总监请选择对口装置。<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp4、副部长（不兼任装置长）千万不要选择！！！！兼任装置长的副部长请选择对口装置。<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp5、书记（不兼任装置长）千万不要选择！！！！<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp6、部长千万不要选择！！！！<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp7、装置长千万不要对自己所管辖的装置进行重复选择，系统已自动设定，例如：12000吨/年DCP装置长第一步注册时二级单位显示为12000吨/年DCP装置，则第二步注册时千万不能再次选择12000吨/年DCP装置。<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp8、目前有如下装置还没有对应装置长，如下所示：<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp1）炼油一部18万吨/年石蜡发汗装置、12万吨/年石蜡精制装置<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp2）炼油二部25万吨/年糠醛精制装置、#7罐区<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp3）炼油三部6万标立方米/时火炬气回收装置<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp4）炼油四部催化重整C6分离<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp5）炼油五部#1制加氢联合装置<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp6）化工二部10万吨/年高纯级苯酚丙酮装置、苯酚罐区、三异丁基铝装置<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp7）化工四部加成缩合装置、BIPB中试装置<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp8）产品分析和技术服务中心分析四站<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp9）储运二部仓储作业一区、仓储作业二区、仓储作业三区、仓储作业四区、仓储作业五区<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp10）动力管理中心锅炉和脱硫装置<br>
解决方法如下：<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp1）有的装置是副部长、安全总监或组长兼任，请副部长、安全总监和组长选择兼任的装置。<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp2）有的装置没有人对应，请作业部按照分工落实相应的组长选择（例如储运二部的五个仓储作业区）<br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp3）有的装置属于联合装置范围内，请联合装置长选择。<br><br>
		</td>
	</tr>
	<%
	if ((theRole.getRoleType() & (Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
			| Constants.ROLE_TYPE_BUZHANG)) > 0 || theDepart1.getDepartmentType() == Constants.DEPARTMENT_TYPE_JIGUAN) {
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">对口管理组：</span>
			<input type="button" value="添加对口管理组" 
				onclick="openDialogPage('managegroup_select/managegroup_check_section.jsp?depart1ID='+getElementValueByID('depart1'), 'manageGroupDialog', '选择对口管理组')" />
			<span id="manageGroupListSpan">
			<%@include file="managegroup_list_section.jsp" %>
			</span>
		</td>
	</tr>
	<%
	}
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">关注岗检：</span>
			<input type="button" value="添加关注岗检" onclick="openDialogPage('postcheck_select/postcheck_check_section.jsp', 'postCheckDialog', '选择关注岗检')" />
			<span id="postcheckListSpan">
			<%@include file="postcheck_list_section.jsp" %>
			</span>
		</td>
	</tr>
	<%
	}
	%>
	<%
	if ((theRole.getRoleType() & (Constants.ROLE_TYPE_BUZHANG | Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_ZONGSHI
			| Constants.ROLE_TYPE_FUZONGJINGLI | Constants.ROLE_TYPE_ZONGJINGLI)) > 0) {
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">关注岗检：</span>
			<input type="button" value="添加关注岗检" onclick="openDialogPage('postcheck_select/postcheck_check_section.jsp', 'postCheckDialog', '选择关注岗检')" />
			<span id="postcheckListSpan">
			<%@include file="postcheck_list_section.jsp" %>
			</span>
		</td>
	</tr>
	<%
	}
	%>
	<tr>
		<td class="td1" height="35">
			<span style="margin-left: 30px" class="span1">密 码：</span>
			<input type="password" name="password" id="password" size="15" />
			<span style="margin-left: 20px" class="span1">确认密码：</span>
			<input type="password" name="confirmPassword" id="confirmPassword" size="15" />
			<span style="margin-left: 5px">（可不填写）</span>
		</td>
	</tr>
	<tr>
		<td class="td1" align="center">
			<input type="button" value="完成注册" onclick="register2()" />
		</td>
	</tr>
</table>

<script type="text/javascript">
function register2() {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'register2_process.jsp',
		data:{
			password: getElementValueByID('password'),
			confirmPassword: getElementValueByID('confirmPassword')
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					$.dialog('修改信息成功，请重新登录！', function() { 
						loadPageSection('<%=request.getContextPath()%>/login.jsp', 'mainContentDiv', {}, true);
						loadPageSection('<%=request.getContextPath()%>/menu.jsp', 'mainMenuDiv'); });
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function chooseMappingEquip() {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'choose_equipment1_process.jsp',
		data:{
			id: getElementValueByID('equipID')
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('equip_list_section.jsp', 'equipListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function deleteMappingEquip(equipID) {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'delete_equipment_process.jsp',
		data:{
			id: equipID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('equip_list_section.jsp', 'equipListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function chooseMappingManageGroup() {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'choose_manage_group_process.jsp',
		data:{
			id: getElementValueByID('manageGroupID')
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('managegroup_list_section.jsp', 'manageGroupListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function deleteMappingManageGroup(manageGroupID, depart1ID) {
	$.ajax({
		type:'post',
		url:'delete_managegroup_process.jsp',
		data:{
			id: manageGroupID,
			depart1ID: depart1ID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('managegroup_list_section.jsp', 'manageGroupListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function chooseMappingPostcheck() {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'choose_postcheck_process.jsp',
		data:{
			id: getElementValueByID('checkID')
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('postcheck_list_section.jsp', 'postcheckListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function deleteMappingPostcheck(postCheckID) {
	$.ajax({
		type:'post',
		url:'delete_postcheck_process.jsp',
		data:{
			id: postCheckID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('postcheck_list_section.jsp', 'postcheckListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function chooseMappingShiyebu() {
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'choose_department1_process.jsp',
		data:{
			id: getElementValueByID('depart1')
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('depart1_list_section.jsp', 'depart1ListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}

function deleteMappingShiyebu(depart1ID) {
	$.ajax({
		type:'post',
		url:'delete_department1_process.jsp',
		data:{
			id: depart1ID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('depart1_list_section.jsp', 'depart1ListSpan', {}, false);
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}
</script>
<%
}
%>